Hi, i have a problem with my code
Link lnk
for lnk in (current Object) -> "*" do
{
// do something
}
Error: <Line:2> null Object parameter was passed into argument position 1
what can i do ? meinhana - Mon Nov 30 09:05:43 EST 2015 |
Re: Null Object parameter? It appears that you are not in a module or have not selected an object. |
Re: Null Object parameter? I selected a project/module... Otherwise i search for - for lnk in current Project - or something |
Re: Null Object parameter? Now i use this code... But that don't make me happy...
int count_formals(string folder_path, bool verbose)
{
Item it
Folder f = folder folder_path
if ( null f )
{
return -1
}
int i = 0
int count = 0
for it in f do
{
if ( isDeleted it )
{
continue
}
if ( type(it)=="Formal" || type(it)=="Descriptive")
{
continue
}
if ( verbose )
{
print rootName_(it) "\n"
}
if ( type(it)=="Folder" || type(it)=="Project")
{
count = count + count_formals(fullName it, verbose)
}
if ( type(it)=="Link" )
{
print fullName it "\n"
count ++
}
}
return count
}
int y = count_formals(proPath, verbose)
|
Re: Null Object parameter? meinhana - Tue Dec 01 03:20:44 EST 2015 Now i use this code... But that don't make me happy...
int count_formals(string folder_path, bool verbose)
{
Item it
Folder f = folder folder_path
if ( null f )
{
return -1
}
int i = 0
int count = 0
for it in f do
{
if ( isDeleted it )
{
continue
}
if ( type(it)=="Formal" || type(it)=="Descriptive")
{
continue
}
if ( verbose )
{
print rootName_(it) "\n"
}
if ( type(it)=="Folder" || type(it)=="Project")
{
count = count + count_formals(fullName it, verbose)
}
if ( type(it)=="Link" )
{
print fullName it "\n"
count ++
}
}
return count
}
int y = count_formals(proPath, verbose)
Your questions(?) don't make me happy. Please inform yourself on how to ask for help on forums and come back with a description of what you want to achieve, and where exactly your problem is. Regards, Mathias |
Re: Null Object parameter? Mathias Mamsch - Tue Dec 01 17:34:43 EST 2015 Your questions(?) don't make me happy. Please inform yourself on how to ask for help on forums and come back with a description of what you want to achieve, and where exactly your problem is. Regards, Mathias HI, my question is why this not works although i select a project or a module ...
Link l
for l in (current Object) -> "*" do
{
// do something
}
and i search for a other method to get the link information
btw. i have the same problem with that - same error : null Object parameter ...
Module m = current
Object o
for o in m do
{
// do something
}
no matter what i do, my object "o" is null, and i don't know how to fix that |
Re: Null Object parameter? meinhana - Wed Dec 02 03:03:55 EST 2015 HI, my question is why this not works although i select a project or a module ...
Link l
for l in (current Object) -> "*" do
{
// do something
}
and i search for a other method to get the link information
btw. i have the same problem with that - same error : null Object parameter ...
Module m = current
Object o
for o in m do
{
// do something
}
no matter what i do, my object "o" is null, and i don't know how to fix that There is nothing wrong with your code as such, provided you run it in the right context, i.e. as stated before, from within an open module. In the first snippet you also need a current object to avoid an error. Moreover you need at least one outgoing link from the current object to get any result. In the second snippet you cannot get the a "null Object..." error. However, you can get a "null Module..." error if you don't run the code from within a module. To get any result you will need at least one object in the current display set. Sorry, but from this thread you seem to lack a basic understanding of DOORS. Your code (first snippet) loops through outgoing links of a single DOORS object. But between the lines I read you want to loop through links of an entire project or at least an entire module? Combining your snippets would get you closer to that goal. |
Re: Null Object parameter? morast - Wed Dec 02 09:25:18 EST 2015 There is nothing wrong with your code as such, provided you run it in the right context, i.e. as stated before, from within an open module. In the first snippet you also need a current object to avoid an error. Moreover you need at least one outgoing link from the current object to get any result. In the second snippet you cannot get the a "null Object..." error. However, you can get a "null Module..." error if you don't run the code from within a module. To get any result you will need at least one object in the current display set. Sorry, but from this thread you seem to lack a basic understanding of DOORS. Your code (first snippet) loops through outgoing links of a single DOORS object. But between the lines I read you want to loop through links of an entire project or at least an entire module? Combining your snippets would get you closer to that goal. Thanks for your answer, and maybe i'm not good at dxl, but i'm still looking for the answer.... It cant be so difficult to iterate through the links... I just want to select an project and find all the link modules and get the information
How can i open a module? Selecting it or open it in DOOORS or i need to write something like "read(m)" in dxl ? Thanks... |
Re: Null Object parameter? meinhana - Wed Dec 02 09:44:06 EST 2015 Thanks for your answer, and maybe i'm not good at dxl, but i'm still looking for the answer.... It cant be so difficult to iterate through the links... I just want to select an project and find all the link modules and get the information
How can i open a module? Selecting it or open it in DOOORS or i need to write something like "read(m)" in dxl ? Thanks... If you want to loop through all links in a folder (a project is a special kind of folder) you have to - Loop through all items of the folder - Identify any module and open it - Loop through objects in the module - Loop through links in each object. Could take some time. Here is an outline of what you have to do. It''s not recursive so it will not open modules in sub-folders, only modules placed directly in the current folder. Then of course there are a lot of ifs and buts that any DXL code should take are of that this outline does not.
Folder f = current
Item itm
Module m
Object o
Link l
for itm in f do
{
if ( type(itm) == "Formal" )
{
m = read(fullName itm)
for o in m do
{
for l in o -> "*" do
{
// do something
}
}
close m
}
}
|
Re: Null Object parameter? meinhana - Wed Dec 02 09:44:06 EST 2015 Thanks for your answer, and maybe i'm not good at dxl, but i'm still looking for the answer.... It cant be so difficult to iterate through the links... I just want to select an project and find all the link modules and get the information
How can i open a module? Selecting it or open it in DOOORS or i need to write something like "read(m)" in dxl ? Thanks... Two more things. 1. Are you aware you can run DXL both from the DOORS database window and from within a Module? Menu Tools > Edit DXL... In the latter case you will definitely have a current module. 2. Links are NOT stored in link modules! A link is stored in the source object, i.e. within a regular formal module. |
Re: Null Object parameter? morast - Wed Dec 02 09:53:13 EST 2015 If you want to loop through all links in a folder (a project is a special kind of folder) you have to - Loop through all items of the folder - Identify any module and open it - Loop through objects in the module - Loop through links in each object. Could take some time. Here is an outline of what you have to do. It''s not recursive so it will not open modules in sub-folders, only modules placed directly in the current folder. Then of course there are a lot of ifs and buts that any DXL code should take are of that this outline does not.
Folder f = current
Item itm
Module m
Object o
Link l
for itm in f do
{
if ( type(itm) == "Formal" )
{
m = read(fullName itm)
for o in m do
{
for l in o -> "*" do
{
// do something
}
}
close m
}
}
Thank you for your help
Can you give me a little bit more help ? Now i can iterate through the whole project and find all links but i don't come in the loop through the links (for l in o->"*" do) I need to find the incoming and outgoing links in a link module... |
Re: Null Object parameter? meinhana - Thu Dec 03 03:10:27 EST 2015 Thank you for your help
Can you give me a little bit more help ? Now i can iterate through the whole project and find all links but i don't come in the loop through the links (for l in o->"*" do) I need to find the incoming and outgoing links in a link module... Sorry, I'm not sure I understand the question. Probably because I don't understand the sentance "...but i don't come in the loop through the links" Please note that a Link Module is NOT a container of links. It is a container of linksets. The star in the for l in o -> "*" loop is a wildcard, it translates to any link module. If you want to limit to a specific link module you provide the name of that link module instead of the star: for l in o -> "MyLinkModule" do
|
Re: Null Object parameter? morast - Thu Dec 03 07:44:15 EST 2015 Sorry, I'm not sure I understand the question. Probably because I don't understand the sentance "...but i don't come in the loop through the links" Please note that a Link Module is NOT a container of links. It is a container of linksets. The star in the for l in o -> "*" loop is a wildcard, it translates to any link module. If you want to limit to a specific link module you provide the name of that link module instead of the star: for l in o -> "MyLinkModule" do
Ok, maybe we talk at cross purposes ... Please have a look at my code...
Project p = current
string slash = "/"
string nameP = name(p)
string x = slash nameP
string proPath = x
void getLink(string folder_path)
{
Folder f = folder folder_path
Item it
Module m
Object o
Link l
if ( null f )
{
return -1
}
else
{
for it in f do
{
if ( isDeleted it )
{
continue
}
if ( type(it)=="Formal" || type(it)=="Descriptive")
{
continue
}
if ( type(it)=="Folder" || type(it)=="Project")
{
getLink(fullName it)
}
if ( type(it) == "Link" )
{
print fullName it "\n"
//string s = fullName it
m = read(fullName it)
for o in m do
{
print "for1\n"
for l in o -> "Link1" do //"*"
{
// do something
print "for2\n"
}
}
close m
}
}
}
}
getLink(proPath)
Output:
[progress] Executing /Test/Test5.dxl [progress] Done.
This is what i mean with "don't come to the loop" (for2) I try to get the linkset information ( where the link start and where the link end)
|
Re: Null Object parameter? meinhana - Thu Dec 03 08:02:12 EST 2015 Ok, maybe we talk at cross purposes ... Please have a look at my code...
Project p = current
string slash = "/"
string nameP = name(p)
string x = slash nameP
string proPath = x
void getLink(string folder_path)
{
Folder f = folder folder_path
Item it
Module m
Object o
Link l
if ( null f )
{
return -1
}
else
{
for it in f do
{
if ( isDeleted it )
{
continue
}
if ( type(it)=="Formal" || type(it)=="Descriptive")
{
continue
}
if ( type(it)=="Folder" || type(it)=="Project")
{
getLink(fullName it)
}
if ( type(it) == "Link" )
{
print fullName it "\n"
//string s = fullName it
m = read(fullName it)
for o in m do
{
print "for1\n"
for l in o -> "Link1" do //"*"
{
// do something
print "for2\n"
}
}
close m
}
}
}
}
getLink(proPath)
Output:
[progress] Executing /Test/Test5.dxl [progress] Done.
This is what i mean with "don't come to the loop" (for2) I try to get the linkset information ( where the link start and where the link end)
Again, a link module is NOT a container of links.! The for l in o loop only does not make sence in a Link module, only for objects in formal modules. Please read the "accepted answer" post.
|
Re: Null Object parameter? morast - Thu Dec 03 08:27:08 EST 2015 Again, a link module is NOT a container of links.! The for l in o loop only does not make sence in a Link module, only for objects in formal modules. Please read the "accepted answer" post.
Well, thanks...this is so embarrassing, it works thank you very much
|